﻿using UnityEngine;
using UnityEngine.UI;

public class Process : MonoBehaviour {

    public Image ProcessImg;
    public float Target;

    private float total;
    private bool start;
	
	public void Update () {
        if (start)
        {
            ProcessImg.fillAmount = total / Target;
            total += Time.deltaTime;
            if (total > Target)
            {
                End();
            }
        }
	}

    public void StartProcess(float target)
    {
        Target = target;
        total = 0f;
        start = true;
    }

    public void End()
    {
        start = false;
        gameObject.SetActive(false);
    }
}
